<?php
namespace App\Service\Admin;

class IndexService extends BaseService
{
    //登录

    //登录
    public static function dologin($uname, $passwd)
    {
        $res = self::dbConn(self::$dbAdmin)
            ->where('name', $uname)
            ->first();
        if (!$res) {
            return self::toback(-2, '账号不存在');
        }
        if ($res->passwd != md5($passwd)) {
            return self::toback(-2, '密码错误');
        }
        $resData = [
            'admin_id' => $res->id,
            'admin_name' => $uname,
        ];
        return self::toback(0, '', $resData);
    }
}